package org.example.flinktest.apidemo;

import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.environment.CheckpointConfig.ExternalizedCheckpointCleanup;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author SHB
 */
public class CheckpointDemo {

  public static void main(String[] args) throws Exception {
;


    //定义流环境
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    //检查点设置
    env.enableCheckpointing(6000);
    //设置检查点模式
    env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.AT_LEAST_ONCE);
    //checkpoint失败是否job失败
    env.getCheckpointConfig().setFailOnCheckpointingErrors(false);
    //同时运行checkpoint的最大值
    env.getCheckpointConfig().setMaxConcurrentCheckpoints(1);
    //
    env.getCheckpointConfig().enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION);
    //重启策略
    env.setRestartStrategy(RestartStrategies.fixedDelayRestart(3,500));




  }

}
